package com.yao.club.controller;

import com.yao.club.entity.result.ResponseEntity;
import com.yao.club.service.FileUploadService;
import com.yao.club.token.PassToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/app/file")
@Api(value = "文件上传接口", tags = "文件上传模块")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PassToken
    @PostMapping("/upload")
    @ApiOperation(value = "上传文件", notes = "支持图片格式：jpg、jpeg、png、gif")
    public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) {
        return fileUploadService.uploadFile(file);
    }
    @PassToken
    @PostMapping("/uploadMultiple")
    @ApiOperation(value = "批量上传文件", notes = "支持多个图片同时上传")
    public ResponseEntity<List<String>> uploadMultipleFiles(@RequestParam("files") MultipartFile[] files) {
        return fileUploadService.uploadMultipleFiles(files);
    }
} 